using System;
using System.Collections;
using App_Code.Modules;
using Portal.Core.Helper;
using Portal.Data.Entity;
using System.Web.UI.WebControls;

public partial class Modules_WebpartDefinition_List : WebpartDefinitionModule
{
    private const int PageSize = 50;
    protected override string Action
    {
        get
        {
            return "lists";
        }
    }
    protected override void OnLoad(EventArgs e)
    {
        if (!IsPostBack)
        {
            int count;
            IList list = WebpartDefinition.Paging(PageSize, GetCurrentPage(null), out count);

            Contents.DataSource = list;
            Contents.DataBind();

            AddPagingTool(new System.Web.UI.Control[] { phPagingBottom }, count, PageSize, null);
        }
    }

    protected void Contents_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int ID = Convert.ToInt32(e.CommandArgument);
        if (e.CommandName == "Delete")
        {
           (WebpartDefinition.FindByPrimaryKey(ID)).Delete();
            Forward("delete");
        }
        else if (e.CommandName == "Edit")
        {
            ActionPage.newParams.Add("id", ID);
            Forward("edit");
        }
    }
}
